﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    API Document - Open API Control Panel
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript" src="/ckeditor/ckeditor.js"></script>

    <fieldset>
        <legend>Document Manage &gt; Add</legend>
        <div class="editor-label">
            <font color="red">*</font>Doc Code:
        </div>
        <div class="editor-field">
            <%= Html.TextBox("txtDOC_CD","",new {@style=" width:250px;"}) %>
        </div>
        <div class="editor-label">
            <font color="red">*</font>Doc Subject:
        </div>
        <div class="editor-field">
            <%= Html.TextBox("txtDOC_SUBJECT","",new {@style=" width:250px;"}) %>
        </div>
        <div class="editor-label">
            Doc Tags:
        </div>
        <div class="editor-field">
            <%= Html.TextBox("txtDOC_TAGS", "", new { @style = " width:250px;" })%>
        </div>
        <div class="editor-label">
            <font color="red">*</font>Doc Author:
        </div>
        <div class="editor-field">
            <%= Html.TextBox("txtDOC_AUTHOR", Session["USER_NAME"].ToString(), new { @style = " width:250px;",@disabled="disabled" })%>
        </div>
        <div class="editor-label">
            <font color="red">*</font>Doc Body:
        </div>
        <div class="editor-field">
            <textarea cols="80" id="editor1" name="editor1" rows="10"></textarea>

            <script type="text/javascript">
                //<![CDATA[

                CKEDITOR.replace('editor1',
					{
					    skin: 'kama',
					    fullPage: true,
					    htmlEncodeOutput: true,
					    toolbar:
				        [
                            ['Source', '-', 'Save', 'NewPage', 'Preview', '-', 'Templates'],
                            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Print', 'SpellChecker', 'Scayt'],
                            ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
					    //['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
                            '/',
                            ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript'],
                            ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
                            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
                            ['Link', 'Unlink', 'Anchor'],
                            ['Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak'],
                            '/',
                            ['Styles', 'Format', 'Font', 'FontSize'],
                            ['TextColor', 'BGColor'],
                            ['Maximize', 'ShowBlocks', '-', 'About']
                        ]

					});
                //]]>
            </script>

            <p>
                <input type="button" id="btnSubmitAdd" name="btnSubmitAdd" value="Add Document" />
                <input type="button" id="btnGoToList" name="btnGoToList" value="Go To List" />
            </p>
        </div>
    </fieldset>

    <script type="text/javascript" language="javascript">

        //json: Submit
        $().ready(function() {
            $("#btnSubmitAdd").click(function() {

                var doc_cd = $("input[name='txtDOC_CD']")[0].value;
                var doc_subject = $("input[name='txtDOC_SUBJECT']")[0].value;
                var doc_tags = $("input[name='txtDOC_TAGS']")[0].value;
                var doc_author = $("input[name='txtDOC_AUTHOR']")[0].value;
                var doc_body = CKEDITOR.instances.editor1.getData();

                $("input[name='btnSubmitAdd']")[0].disabled = "disabled";
                $("input[name='btnSubmitAdd']")[0].value = "Add Document...";

                $.post("/Document/Add?" + new Date(), {
                    Action: "post",
                    doc_cd: doc_cd,
                    doc_subject: doc_subject,
                    doc_tags: doc_tags,
                    doc_author: doc_author,
                    doc_body: doc_body
                }, function(result) {
                    if (result.FLAG) {
                        alert(result.DESC);
                        $("input[name='btnSubmitAdd']")[0].disabled = "";
                        $("input[name='btnSubmitAdd']")[0].value = "Add Document";
                        location.href = "/Document/Add";
                    }
                    else {
                        alert(result.DESC);
                        $("input[name='btnSubmitAdd']")[0].disabled = "";
                        $("input[name='btnSubmitAdd']")[0].value = "Add Document";
                    }
                })
            })
        })



        $().ready(function() {
            $("#btnGoToList").click(function() {
                location.href = "/Document/List";
            })
        })
        

    </script>

</asp:Content>
